paths=[["B","C"],["D","B"],["C","A"]]
# def find(paths,cur_location):
#     for i in range(1,len(paths)):
#         if cur_location==paths[i][0]:
#             cur_location=paths[i][1]
#     return cur_location
#
# def destCity(paths):
#     paths_len=len(paths)
#     if paths_len==1:
#         return paths[0][1]
#     cur_location=paths[0][1]
#     #无法直接知道需要迭代的次数
#     #for i in range(1,paths_len):
#     while cur_location !=find(paths,cur_location):
#         cur_location=find(paths,cur_location)
#     print(cur_location)
# destCity(paths)
def find(paths,cur_location,ans):
    cur=cur_location
    for i in range(len(paths)):
        if cur==paths[i][0]:
            cur=paths[i][1]
            break
    if cur==cur_location:
        #表示这个点就是最后一个城市
        ans.append(cur_location)
        return None
    else:
        find(paths,cur,ans)
def destCity(paths):
    cur_location=paths[0][1]
    #用于存放结果城市
    ans=[]
    find(paths,cur_location,ans)
    print(ans[0])
destCity(paths)